import { cloudResIndex, businesxz, removeFile } from '@/services/knowledgemanagement';

export default {
  namespace:'businessDocuments',

  state: {
  
  },
  effects: {
    *cloudResIndex({ payload, callback }, { call, put }) {
      const response = yield call(cloudResIndex, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *businesxz({ url, payload, callback }, { call, put }) {
      const response = yield call(businesxz, url, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *removeFile({ payload, callback }, { call, put }) {
      const response = yield call(removeFile, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
    clear() {
      return {
       
      };
    },
  },
};
